package lab3;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Stuff {
	public static void main (String[] args)
	{
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		int[][] a = new int[5][5];
		long sum = 0;
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < a.length; i++)
		{
			for (int j = 0; j < a[0].length; j++)
			{
				a[i][j]=sc.nextInt();
				sum+=a[i][j];
				if (!map.containsKey(a[i][j]))
				{
					map.put(a[i][j],1);
				}
				else map.put(a[i][j], map.get(a[i][j])+1);
			}
		}
		int max=Integer.MIN_VALUE;
		int mostFrequent=0;
		for (Map.Entry<Integer, Integer> entry : map.entrySet())
		{
			if (entry.getValue()>max) mostFrequent=entry.getKey();
		}
		System.out.println(sum);
		System.out.println(mostFrequent);
	}
}
